package com.mh.example.xml.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;

/**
 * 在xml中开启注解方式配置切面
 */
@Aspect
public class UserAspectEnableAnnotation {

	@Pointcut("execution(* com.mh.example.xml.aop.UserService.add(..))")
	public void pointcut() {
	}

	@Before("pointcut()")
	public void before() {
		System.out.println("Before...");
	}

	@Around("pointcut()")
	public void around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
		System.out.println("Around Before ...");
		// 执行被增强的目标方法
		proceedingJoinPoint.proceed();
		System.out.println("Around After ...");
	}

}
